<div class="container">





<div class="row">
    <div class="col-md-12">    
        <ol class="breadcrumb">
            <li>
                <a href="<?=base_url('main')?>">首页</a>
            </li>
            <li><a href="<?=base_url('main/catagory/') . $post["posts_catagory"]?>"><?=$catagory_title?></a></li>
            <li class="active">Post Edit</li>
        </ol>
    </div>
</div>





    <?php //var_dump($post); ?>
    <?php //var_dump($catagory_title); ?>



<form action="<?=base_url('main/post_update')?>" method="POST" role="form" enctype="multipart/form-data">
    <legend>修改POST</legend>


    
    <div class="form-group">
        <input type="hidden" name="posts_id" value="<?=$post["posts_id"]?>">
        <input type="hidden" name="posts_catagory" value="<?=$post["posts_catagory"]?>">
    </div>




<div class="row">
    <div class="col-md-6">
    
    

    <div class="panel panel-default">
        <div class="panel-heading">Content</div>
        <div class="panel-body">
            <div class="form-group">
                <textarea name="posts_content" cols="30" rows="10" class="form-control"><?=$post["posts_content"]?></textarea>
            </div>
        </div>
    </div>




<div class="panel panel-default">
    <div class="panel-heading">Files</div>
    <div class="panel-body">

        <label>File list</label>
        <div class="form-group">
            <table class='table table-bordered table-striped"'>
                <tr>
                    <th>序号</th>
                    <th>标题</th>
                    <th>编辑</th>
                </tr>

                <?php foreach($post["posts_files_array"] as $file_key => $file_value){ ?>
                    <tr>
                        <td><?=$file_key+1?></td>
                        <td>
                            <a target="_blank" href="<?=base_url('/uploads/') . $post['posts_catagory'] . '/' . $file_value["file_newname"]?>">
                                <?=$file_value["file_oldname"]?>(<?=$file_value["file_size"]?>MB)
                            </a>
                            <br><span class="text-muted">上传时间：<?=$file_value["file_ctime"]?></span>
                        </td>
                        <td>
                            <a href="<?=base_url('main/post_filename_edit/' .  $post["posts_catagory"] . '/' .  $file_value["file_post_id"] . '/' . $file_value["file_id"])?>">修改文件名</a>
                        </td>
                    </tr>
                <?php } ;?>
                
            </table>
        </div>

        <hr>

        <label>File upload</label>
        <div class="form-group">
            <div class="well well-sm">
                <input type="file" name="posts_file[]" multiple />
                <!-- <input type="file" class="form-control" name="posts_file" /> -->
            </div>
        </div>
    </div>
</div>






    <button type="submit" class="btn btn-primary">Submit</button>



    
    </div><!-- .col-md-6 -->
    <div class="col-md-6">
    
    <div class="panel panel-default">
    <div class="panel-heading">posts_ctime</div>
    <div class="panel-body">
        <input type="input" name="posts_ctime" value="<?=$post["posts_ctime"]?>">
    </div>
</div>


<div class="panel panel-default">
    <div class="panel-heading">Tag</div>
    <div class="panel-body">

    <div class="form-group">

        <?php foreach($tag_group_array as $tag_group_key => $tag_group_value){ ?>

            <p>Tag Group <?=$tag_group_key?></p>
            <div class="checkbox">

                <?php foreach($tag_group_value as $tag_key => $tag_value){ ?>
                    <label>
                        <!-- $post["posts_tag"] 就是 post 中的tag数组 -->
                        <!-- $tag_value 就是各种的tag信息 -->
                        <!-- if(in_array($tag_value["tag_id"],explode(",",$post["posts_tag"])){echo "checked";}  -->
                        <input type="checkbox" name="posts_tag[]" value="<?=$tag_value["tag_id"]?>" 
                            <?php if(in_array($tag_value["tag_id"],explode(",",$post["posts_tag"]))){echo 'checked';} ;?> 
                        >

                        <?=$tag_value["tag_title"]?>
                    </label>
                <?php } ?>


            </div>
        <?php } ?>

    </div>

    </div>
</div>


    </div><!-- .col-md-6 -->
</div>



















</form>





</div>